<template>
    <div id="tab">
        <ul>    
            <li  :class="current === i ? 'active' : ''"  
                v-for="(item,i) in tab" :key="i" @click="tabClick(i)"
            >{{item}}</li>
        </ul>        
    </div>
</template>

<script>
export default {
    name: 'Tab',
    props:{
        tab:Array
    },
    data() {
        return {
            current:0
        };
    },
    created() {
    },
    methods: {
        tabClick(i) {
            this.current = i
            if(i === 0) {
                this.$router.push('/')
            } else if(i === 1) {
                this.$router.push('/type')
            } else if(i === 2) {
                this.$router.push('/cart')
            } else if(i === 3) {
                this.$router.push('/my')
            }
        }
    },
    //组件挂载
    components: {},
    //计算属性
    computed: {},
    //过滤器
    filters: {},
};
</script>

<style lang="scss" scoped>
#tab{
    width: 100%;
    height: 1rem;
    background-color: #fff;
    ul{
        display: flex;
        justify-content: space-around;
        align-items: center;
        height: 100%;
        li{
            flex-basis: 25%;
            text-align: center;
            line-height: 1rem;
            font-size: .24rem;
        }
        .active{
            color: red;
        }
    }
}
</style>
